<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>{:C('MANUFACTURER')}</title>
    <import type='css' file="css.bootstrap#min" />
    <import type='css' file="css.font-awesome#min" />
    <!--[if lt IE 9]>
    <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <import file="js.jquery-1#11#0#min" />
    <import file="js.bootstrap#min" />
    <import file="js.jquery#validate#min" />
    <import file="js.respond" />
    <import file="js.jquery#form#min" />
    <import file="js.alertify#min" />
</head>
<body>
    <style type="text/css">
    .login-container-out {
        width: 100%;
        background: #000000;
    }
    .login-container-in {
        width: 100%;
        margin: 0 auto;
    }
    .login-container {
        height: 500px;
        background: url('__PUBLIC__/img/background.jpg') center;
        background-repeat: no-repeat;
    }
    .form-signin {
        position: relative;
        left: 250px;
        top: 90px;
        z-index: 2;
        max-width: 290px;
        padding: 4px 19px 29px 29px;
        margin: auto;
        background: #FFFFFF;
        -moz-opacity:0.9;
        filter:alpha(opacity=90);
        opacity: 0.9;
        /*background:rgba(255,255,255,.5);*/
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        border-radius: 5px;
        -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
        -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
        box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
    }
    .input-group{
        width:230px;
        margin-bottom: 5px;
    }
    .input-group-addon{
        width:50px;
    }
    .verify{
        width:97px;
    }
    .bg-danger{
        font-size: 13px;
        width:230px;
        padding: 5px;
    }
    .bg-success{
        font-size: 13px;
        width:230px;
        padding: 5px;
    }
    .footer {
        width: 100%;
        height: 100%;
        padding: 20px 0;
    }
    .header {
        width: 100%;
        height: 100%;
        padding-top: 20px;
        padding-bottom: 10px;
    }

    .logoimg{
        height: 60px;
    }
    .btn-link{
        font-size: 13px;
    }
    .right-foot{
        font-size: 13px;
    }
    .left-foot a:hover{
        color:red;
        text-decoration:none;
    }
</style>
    <div class="header">
        <div class="login-container-in">
            <img class="logoimg" src="__PUBLIC__/img/cdlogo.jpg"/>
        </div>
    </div>
    <div class="">

        <div class="login-container login-container-in">
            <form class="form-signin" id="form-signin" action="__URL__/check" style="background-color: #F3F7FA" method="post">
                <h2 class="form-signin-heading">
                    <img src="__PUBLIC__/img/llly.png" style="max-width: 95%"  class="img-responsive" />
                </h2>
                <div class="input-group">
                    <span class="input-group-addon"><i class="fa fa-user"></i>
                    </span>
                    <input type="text" class="form-control" name="fac_login_name" id="fac_login_name" placeholder="请输入登录帐号">
                </div>
                <div class="input-group">
                    <span class="input-group-addon"><i class="fa fa-key"></i>
                    </span>
                    <input type="password" class="form-control" name="fac_password" id="password" placeholder="请输入密码">
                </div>
                <div class="input-group" id="verify-div" style="display:none;">
                    <span class="input-group-addon verify" style="padding:0"><img id="verifyid" src={:U("Login/verify")} class="img-responsive"/>
                    </span>
                    <input type="text" class="form-control" name="verify" id="verify" placeholder="请输入验证码">
                </div>
                <div class="input-group">
                    <button type="submit" name="logintype" value="1" class="btn btn-warning pull-right"><i class="fa fa-sign-in"></i>&nbsp;登录</button>
                </div>
                <p class="bg-danger" style="display:none;"></p>
                <p class="bg-success" style="display:none;"></p>
            </form>
        </div>

    </div>
    <div class="footer">
        <div class="login-container-in">
            <p class="right-foot pull-right">
                <span><a href="http://www.dz.tt/" target="_blank">{:C('COMPANY')}</a> ©版权所有  |  技术支持：<a href="http://www.dz.tt/" target="_blank">{:C('COMPANY')}</a></span>
            </p>
        </div>
    </div>

<script>
    $(document).ready(function(){
            $("#fac_login_name").focus();
    });
    var siteConf = {
        action:'{$action}',
        index:'{$index}',
        token:'{$token}',
    };
    function changeVerify(){
        $("#verifyid").attr("src",'{:U("Login/verify")}');
    }
    function alertError(msg) {
        $(".bg-danger").html('<i class="fa fa-times"></i>&nbsp;' + msg);
        $(".bg-success").hide();
        $(".bg-danger").show();
    }
    function alertInfo(msg) {
        $(".bg-success").html('<i class="fa fa-spinner fa-spin"></i>&nbsp;' + msg);
        $(".bg-danger").hide();
        $(".bg-success").show();
    }
    $(document).ready(function () {
        $("#verifyid").click(function(){
            changeVerify();
        });
        $("#form-signin").ajaxForm({
            dataType:'json',
            clearForm:false,
            beforeSerialize:function(){
                if ($('#password').val() == '' || $('#fac_login_name').val() == '') {
                    alertError("用户名和密码不能为空!");
                    return false;
                }
                var password = $('#password').val();
                password = base64encode(utf16to8(siteConf.token+password));
                $('#password').val( password );
                alertInfo("系统正在验证您的身份...");
                return true;
            },
            success:function(data){
                if (data.state == 0) {
                    if(data.verify == 1){
                        $("#verify-div").show();
                    }
                    $('#password').val( '' );
                    alertError(data.msg);
                    changeVerify();
                } else {
                    alertInfo(data.msg);
                    location.href = siteConf.index;
                }
            }
        });

    });

    var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    var base64DecodeChars = new Array(
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
        52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
        -1,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14,
        15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
        -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
        41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1);
    //编码的方法
    function base64encode(str) {
        var out, i, len;
        var c1, c2, c3;
        len = str.length;
        i = 0;
        out = "";
        while(i < len) {
        c1 = str.charCodeAt(i++) & 0xff;
        if(i == len)
        {
            out += base64EncodeChars.charAt(c1 >> 2);
            out += base64EncodeChars.charAt((c1 & 0x3) << 4);
            out += "==";
            break;
        }
        c2 = str.charCodeAt(i++);
        if(i == len)
        {
            out += base64EncodeChars.charAt(c1 >> 2);
            out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));
            out += base64EncodeChars.charAt((c2 & 0xF) << 2);
            out += "=";
            break;
        }
        c3 = str.charCodeAt(i++);
        out += base64EncodeChars.charAt(c1 >> 2);
        out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));
        out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6));
        out += base64EncodeChars.charAt(c3 & 0x3F);
        }
        return out;
    }
    function utf16to8(str) {
        var out, i, len, c;
        out = "";
        len = str.length;
        for(i = 0; i < len; i++) {
        c = str.charCodeAt(i);
        if ((c >= 0x0001) && (c <= 0x007F)) {
            out += str.charAt(i);
        } else if (c > 0x07FF) {
            out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
            out += String.fromCharCode(0x80 | ((c >>  6) & 0x3F));
            out += String.fromCharCode(0x80 | ((c >>  0) & 0x3F));
        } else {
            out += String.fromCharCode(0xC0 | ((c >>  6) & 0x1F));
            out += String.fromCharCode(0x80 | ((c >>  0) & 0x3F));
        }
        }
        return out;
    }
    function utf8to16(str) {
        var out, i, len, c;
        var char2, char3;
        out = "";
        len = str.length;
        i = 0;
        while(i < len) {
        c = str.charCodeAt(i++);
        switch(c >> 4)
        { 
          case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
            // 0xxxxxxx
            out += str.charAt(i-1);
            break;
          case 12: case 13:
            // 110x xxxx   10xx xxxx
            char2 = str.charCodeAt(i++);
            out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
            break;
          case 14:
            // 1110 xxxx  10xx xxxx  10xx xxxx
            char2 = str.charCodeAt(i++);
            char3 = str.charCodeAt(i++);
            out += String.fromCharCode(((c & 0x0F) << 12) |
                           ((char2 & 0x3F) << 6) |
                           ((char3 & 0x3F) << 0));
            break;
        }
        }
        return out;
    }
</script></body>
</html>